<?php
_header_("Cache-Control: private");
/*Online*/
require_once getCacheFilePath('plugins.php');

//是否允许访问论坛
if(getPopedom(0)==0){
	printMsg('popedom_0');
}

$pathinfo=pathinfo($_SERVER['PHP_SELF']);

$online['ip'] = getIP();
$online['activetime'] = time();
$online['fid'] = intval($fid);
$online['tid'] = intval($tid);
$online['atpage'] = $pathinfo['filename'];

if(isLogin()){
	if($lg['userhidden']==0){
		$online['userid']=$lg['userid'];
		$online['username']=$lg['username'];
		$online['groupid']=$lg['groupid'];
		$onlinerow = $db->row_query("Select (Select groupid from `{$db->pre}online` Where userid={$online['userid']}  Limit 1) As groupid, (Select Count(0) from `{$db->pre}online`) As c");
			if(intval($cache_settings['onlinemostnum'])>0 && intval($onlinerow[0]['c'])>intval($cache_settings['onlinemostnum']) && $lg['groupid']<200){
			printMsg('online_max');
		}
		if(empty($onlinerow[0]['groupid'])){
			$db->row_insert("online",$online);
		}else{
			$db->row_update("online",$online,"userid={$online['userid']}");
		}
	}
}else{
	$online['userid']=0;
	$online['username']='';
	$online['groupid']= GROUP_GUESS;
	$onlinerow = $db->row_query("Select (Select groupid from `{$db->pre}online` Where ip='{$online['ip']}' and userid=0  Limit 1) As groupid, (Select Count(0) from `{$db->pre}online`) As c");
	if(intval($cache_settings['onlinemostnum'])>0 && intval($onlinerow[0]['c'])>intval($cache_settings['onlinemostnum'])){
		printMsg('online_max');
	}
	if(empty($onlinerow[0]['groupid'])){
		$db->row_insert("online",$online);
	}else{
		$db->row_update("online",$online,"ip='{$online['ip']}' and userid=0");
	}
}

$db->row_delete("online", "activetime<".(time()-$cache_settings['onlinekeeptime']*60)."");
$headtitle=(empty($headtitle)? $cache_settings['bbsname'] : "{$headtitle} - {$cache_settings['bbsname']}")." - Powered by 6kbbs";

if(!empty($fid)){
	$_SYS['positionforum'] = "";
	$tmpforum = $cache_forums[$fid];
	if($cache_forums[$tmpforum['pid']]['pid']!=0){
		$_SYS['positionforum'].=" » <a href=\"".genUrl("forum.php?fid={$tmpforum['pid']}")."\">{$cache_forums[$tmpforum['pid']]['forumname']}</a>";
	}
	$_SYS['positionforum'].=" » <a href=\"".genUrl("forum.php?fid={$fid}")."\">{$tmpforum['forumname']}</a>";
}

$headmeta="<meta name=\"keywords\" content=\"{$headkeywords}{$cache_settings['metakeywords']}\" />\n"
."<meta name=\"description\" content=\"{$headdesc}{$cache_settings['metadescription']}\" />\n"
."<meta name=\"generator\" content=\"6KBBS v8.0\" />\n"
."<meta name=\"author\" content=\"www.6kbbs.com\" />\n"
."<meta name=\"copyright\" content=\"2003-2010 6KBBS\" />\n"
."<meta name=\"MSSmartTagsPreventParsing\" content=\"True\" />\n"
."<meta http-equiv=\"MSThemeCompatible\" content=\"Yes\" />\n"
."<meta http-equiv=\"x-ua-compatible\" content=\"ie=7\" />";

require_once getTemplatePath('header.htm');
?>
